package com.cmdfut.rxjava.rxjava;


public abstract class Observable<T> implements ObservableSource {

    public static <T> Observable<T> create(ObservableOnSubscribe<T> source) {
        return new ObservableCreate<>(source);
    }

    @Override
    public void subscribe(Observer observer) {
        subscribeActual(observer);
    }

    //子类 实现 订阅
    protected abstract void subscribeActual(Observer<? super T> observer);

    public <R> Observable<R> map(Function<? super T, ? extends R> function) {
        return new ObservableMap(this, function);
    }

    public final Observable<T> subscribeOn() {

        return new ObservableSubscribeOn<>(this);
    }

    public final Observable<T> observeOn() {
        return new ObservableObserveOn<>(this);
    }
}
